/**
 * 修剪二叉搜索树
 * https://leetcode.cn/problems/trim-a-binary-search-tree/submissions/518895213/
 * 通过递归去递归子树，如果子树的值 小于low / 大于 high 就返回 子树的子树
 */
class Solution3 {
    public TreeNode trimBST(TreeNode root, int low, int high) {
        if(root == null) {
            return null;
        }
        root.left = trimBST(root.left,low,high);
        root.right = trimBST(root.right,low,high);
        if(root.val < low) {
            return root.right;
        }
        if(root.val > high) {
            return root.left;
        }
        return root;
    }
}